# 财务
# 添加应付款单02
# 选择未结账
# from selenium import webdriver # 调用webdriver
# from selenium.webdriver.common.by import By # 引入by模块
# from time import sleep # 调用sleep
# from selenium.webdriver.support.select import Select
# driver = webdriver.Chrome() #打开浏览器
# try:
#     driver.maximize_window()  # 最大化浏览器
#     driver.get("http://192.168.1.79/") # 访问crm后台
#     cookie={"name":"PHPSESSID",'value': 'p5tsh1p53643ic9ld0la870gm5'}
#     driver.add_cookie(cookie)
#     driver.get("http://192.168.1.79/crm/index.php?m=finance&a=add&t=paymentorder")  # 访问crm添加产品页面
#     #定位器
#     owner_name_locator=(By.ID,"owner_name")#负责人
#     owner_radio_locator=(By.CSS_SELECTOR,"#d_content > tr > td:nth-child(1) > input[type=radio]")#选择负责人
#     fzr_locator=(By.XPATH,"/html/body/div[8]/div[3]/div/button[1]") #ok按钮
#     payables_locator=(By.ID,"payables")#应付款
#     field_ys_locator=(By.XPATH,"/html/body/div[7]/div[2]/table/tbody[2]/tr[7]/td[1]/input")#选择应付款
#     ui_button_locator=(By.XPATH,"/html/body/div[7]/div[3]/div/button[1]")#点击ok
#     money_locator=(By.ID,"money") #付款金额
#     pay_time_locator=(By.ID,"pay_time")#付款时间
#     status_locator=(By.NAME,"status")#选择未结账
#     yi_status_locator=(By.XPATH,"/html/body/div[5]/div[2]/div/form/table/tbody/tr[7]/td[2]/input[2]")#选择已结账
#     description_locator=(By.XPATH,"/html/body/div[5]/div[2]/div/form/table/tbody/tr[8]/td[2]/textarea")#描述
#     submit_locator=(By.NAME,"submit")#保存
#
#     #查找应付款单元素
#     driver.find_element(*owner_name_locator).click()#查找负责人元素，并点击
#     sleep(2)
#     driver.find_element(*owner_radio_locator).click()#查找按钮
#     sleep(2)
#     driver.find_element(*fzr_locator).click()#查找OK按钮元素，并点击
#     sleep(2)
#     # 查找元素
#     driver.find_element(*payables_locator).click()
#     sleep(2)
#     driver.find_element(*field_ys_locator).click() #查找应付款单元素
#     sleep(2)
#     driver.find_element(*ui_button_locator) .click()#查找ok元素，并点击
#     sleep(2)
#     driver.find_element(*money_locator).send_keys(50000)#查找付款金额元素，并输入内容
#     pay_time_element=driver.find_element(*pay_time_locator)
#     pay_time_element.clear()
#     pay_time_element.send_keys("2022-09-13")
#     # driver.find_element(*status_locator).click()#选择未结账元素，并点击
#     driver.find_element(*yi_status_locator).click()  # 选择已结账元素，并点击
#     driver.find_element(*description_locator).send_keys("下周回款") #查找描述,并输入内容
#     sleep(2)
#     driver.find_element(*submit_locator).click() #查找保存元素，并点击按钮
# except:
#     raise
# finally:
#     sleep(5) # 暂停五秒，并关闭浏览器
#     driver.quit()